var Bmob = require('Bmob-1.6.5.min.js');

function isCourier() {
    var openId = wx.getStorageSync("user_openid");

    const query = Bmob.Query('couriers');


    query.equalTo("openid", "==", wx.getStorageSync("user_openid"));
    query.equalTo("myType", "==", 1);

    
    query.count().then(res => {
        console.log(`共有${res}条记录`)
        if (res > 0) {
            return true;
        }
        else {
            return false;
        }

    });
    
    return false;
     
}
//是否申请过快递员
function isRequestCourier() {
    var openId = wx.getStorageSync("user_openid");

    const query = Bmob.Query('couriers');


    query.equalTo("openid", "==", wx.getStorageSync("user_openid"));
    //query.equalTo("myType", "==", 0);

    query.count().then(res => {
        console.log(`共有${res}条记录`)
        if (res > 0) {
            var a=new Array();
            a.forEach(function(v,i){
                if(v.myType==1) return true;
                if(v.myType==0) return true;
            });
             
        }
        else {
            return false;
        }

    });

}
 
module.exports.isCourier = isCourier;
module.exports.isRequestCourier = isRequestCourier;